/**
* 数据监控 监控查询
*/
<template>
  <div><!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>会议申请</el-breadcrumb-item>
    </el-breadcrumb>

    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="搜索：">
        <el-select v-model="formInline.recordStatus" clearable placeholder="请选择">
          <el-option label="全部" value="" key=""></el-option>
          <el-option label="待审核" value="1" key="1"></el-option>
          <el-option label="已审核" value="2" key="2"></el-option>
          <el-option label="已驳回" value="3" key="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button size="small" type="success" icon="el-icon-plus" @click="check('2')">审核</el-button>
        <el-button size="small" type="danger" icon="el-icon-delete" @click="check('3')">驳回</el-button>
      </el-form-item>
    </el-form>
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" height="500"
              element-loading-text="拼命加载中" style="width: 100%;" @selection-change="selectChange">
      <el-table-column align="center" type="selection" width="55">
      </el-table-column>
      <el-table-column align="center" type="index" label="序号" width="60">
      </el-table-column>
      <el-table-column sortable prop="recordCode" label="会议编码" width="100" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="meetingRoom.roomCode" label="会议室编码" width="150" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="meetingRoom.roomName" label="会议室名称" width="150" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="meetingRoom.roomType" label="会议室类型" width="200">
        <template slot-scope="scope">
          <div>{{scope.row.meetingRoom.roomType == 1?'大型会议室':scope.row.meetingRoom.roomType == 2?'中型会议室':'小型会议室'}}</div>
        </template>
      </el-table-column>
      <el-table-column sortable prop="recordStatus" label="审核状态" width="150" show-overflow-tooltip>
        <template slot-scope="scope">
          <div>{{scope.row.recordStatus==1?'待审核':scope.row.recordStatus==2?'已审核':'已驳回'}}</div>
        </template>
      </el-table-column>
      <el-table-column sortable prop="remark" label="会议说明" width="200" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="beginTime" label="会议开始时间" min-width="150">
        <template slot-scope="scope">
          <div>{{scope.row.beginTime|timestampToTime}}</div>
        </template>
      </el-table-column>
      <el-table-column sortable prop="endTime" label="会议结束时间" min-width="150">
        <template slot-scope="scope">
          <div>{{scope.row.endTime|timestampToTime}}</div>
        </template>
      </el-table-column>
    </el-table>
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
  </div>
</template>

<script>
    import Pagination from '../../components/Pagination'
    import {Get, Post} from "../../api/axiosFun";
    import {timestampToTime, timestampToDate} from "../../utils/util";

    export default {
        data() {
            return {
                loading: false,
                formInline: {
                    pageIndex: 0,
                    pageSize: 10,
                    recordStatus: '',
                },
                listData: [], //数据
                selectData: [],
                // 分页参数
                pageparm: {
                    currentPage: 1,
                    pageSize: 10,
                    total: 10
                },
            }
        },

        // 注册组件
        components: {
            Pagination
        },

        created() {
            this.getdata(this.formInline)
        },

        methods: {
            getdata(parameter) {
                Get("/officeSystem/accountingRecord/selectAll", parameter)
                    .then(result => {
                        if (result.status == 200) {
                            this.listData = result.data.resultList
                            this.pageparm.total = result.data.totalCount
                        } else {
                            this.listData = []
                            this.pageparm.total = result.data.totalCount
                        }
                    })
            },
            // 搜索事件
            search() {
                this.getdata(this.formInline)
            },
            check(status) {
                if(this.selectData.length == 0){
                    this.$message.warning("请选择要操作的数据");
                    return;
                }
                let list = []
                for(let i=0; i<this.selectData.length; i++){
                    delete this.selectData[i].user;
                    delete this.selectData[i].meetingRoom;
                    list.push(this.selectData[i])
                }
                let params = {
                    status: status,
                    list: list
                }
                Post("/officeSystem/accountingRecord/check", {
                    params: JSON.stringify(params)
                }).then(result => {
                    if(result.status == 200){
                        this.$message.success(result.message);
                        this.search();
                    }else{
                        this.$message.error(result.message);
                    }
                })
            },
            selectChange(val) {
                this.selectData = val;
            },
            // 分页插件事件
            callFather(parm) {
                this.formInline.pageIndex = parm.currentPage - 1
                this.formInline.pageSize = parm.pageSize
                this.search()
            },
        }
    }
</script>

<style scoped>
  .user-search {
    margin-top: 20px;
  }
</style>

